<?php
/**
 * @ Fmash Top System
 * @ version: 3.0
 * @ author: i.coffee.smile@mail.com
 * @ date:2011-1-28
 * @ file:pages.php $32
 */
 
if(isset($_GET['b']))
{
	$pagestr="<a href=\"tops.php?p=1&b=$b\">1</a>
	<a href=\"tops.php?p=2&b=$b\">2</a>
	<a href=\"tops.php?p=3&b=$b\">3</a>
	<a href=\"tops.php?p=4&b=$b\">4</a>
	<a href=\"tops.php?p=5&b=$b\">5</a>";
	$pstr = "<span class=\"current\">$page</span>";
	$ostr = "<a href=\"tops.php?p=$page&b=$b\">$page</a>";
	$c = $page-1;
	$d = $page+1;
	if($page==1){
		$newprev ='';
	}else{
		$newprev = "<a id=\"page-prev\" href=\"tops.php?p=$c&b=$b\">«</a>";
	}
	if($page==5){
		$newnext ='';
	}else{
		$newnext = "<a id=\"page-next\" href=\"tops.php?p=$d&b=$b\">»</a>";
	}
}else{
$pagestr=<<<pagest
<a href="tops.php?p=1">1</a>
<a href="tops.php?p=2">2</a>
<a href="tops.php?p=3">3</a>
<a href="tops.php?p=4">4</a>
<a href="tops.php?p=5">5</a>
pagest;
	//$page = isset($_GET['p'])?$_GET['p']:'1';
	$pstr = "<span class=\"current\">$page</span>";
	$ostr = "<a href=\"tops.php?p=$page\">$page</a>";
	$c = $page-1;
	$d = $page+1;
	if($page==1){
		$newprev ='';
	}else{
		$newprev = "<a id=\"page-prev\" href=\"tops.php?p=$c\">«</a>";
	}
	if($page==5){
		$newnext ='';
	}else{
		$newnext = "<a id=\"page-next\" href=\"tops.php?p=$d\">»</a>";
	}
}

$newpage = $newprev.str_replace($ostr,$pstr,$pagestr).$newnext;

